package com.mjw.zstu.controller;

import com.mjw.zstu.entity.Product;
import com.mjw.zstu.resultDto.JsonResult;
import com.mjw.zstu.service.EchartsService;
import com.mjw.zstu.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    EchartsService echartsService;
    @Autowired
    ProductService productService;
    @RequestMapping("add")
    public JsonResult addProduct(@RequestBody Product product){
      return   productService.add(product);
    }
    @RequestMapping("get")
    public JsonResult getProducts(@RequestParam int id,int company_id){
        return  productService.getProcuctSelfExhibition(id,company_id);
    }
    @RequestMapping("edit")
    public JsonResult edit(@RequestBody Product product){
        return productService.editProduct(product);
    }
    @RequestMapping("delete")
    public JsonResult delete(@RequestParam int product_id){
        return productService.delete(product_id);
    }
    @RequestMapping("detail")
    public JsonResult detail(@RequestParam int product_id){
        return productService.getdetail(product_id);
    }
    @RequestMapping("exhibition")
    public JsonResult getProductsbyExhibitionId(@RequestParam int exhibition_id,int company_id){
        return productService.getProcuctSelfExhibition(exhibition_id,company_id);
    }
    @RequestMapping("allproduct")
    public JsonResult getExhibitionProduct(@RequestParam int exhibition_id){
        return productService.exhibitionProduct(exhibition_id);
    }
    @RequestMapping("ten")
    public JsonResult ten(){
        return echartsService.product_ten();
    }



}
